package com.epam.employeebase.dao;

import com.epam.employeebase.dao.exception.DAOException;
import com.epam.employeebase.dao.hibernate.HibernateEmployeeDAO;
import com.epam.employeebase.dao.jdbc.JDBCEmployeeDAO;
import com.epam.employeebase.dao.jpa.JPAEmployeeDAO;

public final class DAOFactory {
	public static final String JPA_DAO_NAME = "JPA";
	public static final String JDBC_DAO_NAME = "JDBC";
	public static final String HIBERNATE_DAO_NAME = "Hibernate";
	
	private static HibernateEmployeeDAO hibernateDAO = new HibernateEmployeeDAO();
	private static JPAEmployeeDAO jpaDAO = new JPAEmployeeDAO();
	private static JDBCEmployeeDAO jdbcDAO = new JDBCEmployeeDAO();
	
	private DAOFactory () {}
	public static IEmployeeDAO getEmployeeDao(String name) throws DAOException{
		switch(name){
			case HIBERNATE_DAO_NAME:
				return hibernateDAO;
			case JPA_DAO_NAME:
				return jpaDAO;
			case JDBC_DAO_NAME:
				return jdbcDAO;
			default: throw new DAOException();
		}
	}
}
